package com.llh.designpatterns.singleton.lazy;

/**
 * <h2>懒汉单例</h2>
 * <p>使用枚举实现</p>
 * <p>还能防止反序列化重新创建新的对象问题</p>
 * <p>CreatedAt: 2019-11-23 21:01</p>
 * <p><a href="mailto:forever2y_y@163.com">SendMailToMe</a></p>
 *
 * @author llh
 */
class Singleton04 {

    private Singleton04() {
    }

    static Singleton04 getInstance() {
        return SingletonEnum.INSTANCE.getSingleton();
    }

    private enum SingletonEnum {
        INSTANCE;

        private Singleton04 singleton;

        SingletonEnum() {
            singleton = new Singleton04();
        }

        public Singleton04 getSingleton() {
            return singleton;
        }
    }
}
